function changeCouponType(printable) {
    if (printable == 1) {
	var type = 'printable';
	$('#printable-url-input').val($('#online-url-input').val());
    } else {
	var type = 'online';
	$('#online-url-input').val($('#printable-url-input').val());
    }
    var divId = 'coupon_' + type + '_form';
    var tabId = 'submit-' + type + '-tab';
    
    $('#coupon_online_form').css('display', 'none');
    $('#coupon_printable_form').css('display', 'none');
    $('#' + divId).css('display', 'block');
}

function check_submit_coupon(form) {
    if (form.store.value == '') {
	alert('Enter store.');
	form.store.focus();
	return false;
    }
    if (form.title.value == '') {
	alert('Enter description.');
	form.title.focus();
	return false;
    }
}

function changeUploadType(type) {
    var divId = 'printable-' + type;
    var tabId = 'printable-' + type + '-tab';
    $('#printable-url').css('display', 'none');
    $('#printable-upload').css('display', 'none');
    $('#printable-url-tab').removeAttr('class');
    $('#printable-upload-tab').removeAttr('class');
    $('#' + divId).css('display', 'block');
    $('#' + tabId).attr('class', 'selected');
}

function checkExtension(filename) {
    var re = /\..+$/;
    var ext = filename.match(re);
    if (allowedFileExt[ext]) {
	return true;
    } else {
	alert("Invalid file type, please select gif, jpg or png file.");
	return false;
    }
}